package com.heima.kafka.listener;

import com.alibaba.fastjson.JSON;
import org.apache.tomcat.jni.User;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * @author Xiao
 * @version 1.0
 * @description 消息消费者
 * @date 2021/11/26
 */
@Component
public class HelloListener {
    @KafkaListener(topics = "itcast-topic")
    public void onMessage(String message){
        if(!StringUtils.isEmpty(message)){
            System.out.println(message);
            User user = JSON.parseObject(message, User.class);
            System.out.println(user);
        }
    }
}
